package processor;

import java.io.File;
import java.util.List;

import util.ClassFileLoader;
import util.Scanner;
import util.TableInfo;

public class TableProcessor implements IProcessor {

	public String process(String url) throws Exception {
		List<File> classFiles = Scanner.getClassFiles(url);
		StringBuilder sql = new StringBuilder();
		for(File file : classFiles){
			Class<?> clazz = ClassFileLoader.loadClass(file);
			TableInfo table = TableInfo.parse(clazz);
			if(table != null) {
				sql.append(table.toString());
				if(table.getToDeleteTableName()!=null) {
					sql.append(table.toDelete());
				}
				if(table.getToNewTableName()!=null) {
					sql.append(table.toNew());
				}
			}
				
			
		}
		return sql.toString();
	}
}
